/****

    activequant - activestocks.eu

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

	
	contact  : contact@activestocks.eu
    homepage : http://www.activestocks.eu

****/
package org.activequant.dao.mock;

import java.util.ArrayList;
import java.util.List;

import org.activequant.core.domainmodel.account.BrokerAccount;
import org.activequant.dao.IBrokerAccountDao;
import org.activequant.util.exceptions.DaoException;

public class MockBrokerAccountDao extends MockDaoSupportBase<BrokerAccount> implements IBrokerAccountDao {
	
	protected MockBrokerAccountDao() {
		super(BrokerAccount.class);
	}

	@Override
	Long getId(BrokerAccount t) {
		return t.getId();
	}

	@Override
	void setId(BrokerAccount t, Long id) {
		t.setId(id);
	}

	public BrokerAccount[] findByHolder(String name) throws DaoException {
		List<BrokerAccount> accounts = new ArrayList<BrokerAccount>();
		
		for(BrokerAccount account : database.values()) {
			if(account.getHolder().equals(name)) {
				accounts.add(account);
			}
		}
		
		return accounts.toArray(new BrokerAccount[0]);
	}
}
